# 遍历数组，比较相邻两个数的大小，左 > 右 则交换位置

def bubble_sort(li):
    n = len(li)
    for i in range(0, n-1):
        for j in range(0, n-i-1):
            if li[j] > li[j+1]:
                li[j], li[j+1] = li[j+1], li[j]
    return li


print(bubble_sort([64, 34, 25, 12, 22, 11, 90, 2]))
